package com.supermali.system;

import com.supermali.creater.GameStarter;
import com.supermali.listener.KeyEventSupport;
import com.supermali.util.FrameRate;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.geom.Point2D;

/**
 * 首页，开始游戏界面
 * */
public class IndexSystem extends AbstractSystem{


    public IndexSystem(GameStarter gameStarter,SystemHelper systemHelper) {
        super(gameStarter,systemHelper);
    }

    @Override
    public void exec(Graphics g, FrameRate frameRate) {
        createIndexImg(g,frameRate.getDiff());
        proccessKey();
    }

    /**
     * 创建首页展示界面
     * */
    private void createIndexImg(Graphics g,long delta){
        // 创建背景图
        gameStarter.show(g,delta);
        ShowLabel.showStr(g,"空格键开始游戏，按键Q发射炮弹，上下左右键控制人物移动", 1*16, 16*16);
        ShowLabel.showStr(g,"1 PLAY GAMES",14*16, 8*16);
    }
    /**
     * 响应按键事件
     * */
    private void proccessKey(){
        if(KeyEventSupport.getPressed(KeyEvent.VK_SPACE)==1){
            getSystemHelper().setSystemStatus(SystemStatus.LOADING);
        }
    }
}
